home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Communications / pcomm / Source / x_win.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-12  |  2.3 KB  |  90 lines

  1. /*
  2.  * Display the file transfer window, and invoke the transfer protocol.
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <curses.h>
  7. #include "config.h"
  8. #include "dial_dir.h"
  9. #include "misc.h"
  10. #include "xmodem.h"
  11.  
  12. void
  13. xfer_win(list, up, type)
  14. char *list;
  15. int up, type;
  16. {
  17.     extern int fd;
  18.     WINDOW *xf_win, *newwin();
  19.     int ack_error, fast;
  20.     void xmodem_mode(), input_off(), line_set(), st_line();
  21.  
  22.     touchwin(stdscr);
  23.     refresh();
  24.     st_line("");
  25.  
  26.     xf_win = newwin(15, 44, 2, 30);
  27.     /*
  28.      * This window should be in the non-blocking mode, so we can
  29.      * scan the keyboard for input while transferring a file.
  30.      */
  31.     tty_noblock(0, TRUE);
  32.                     /* basic window stuff */
  33.     mvwaddstr(xf_win, 2, 14, "Protocol:");
  34.     mvwaddstr(xf_win, 3, 13, "File name:");
  35.     mvwaddstr(xf_win, 4, 13, "File size:");
  36.     mvwaddstr(xf_win, 5, 4, "Error check method:");
  37.     mvwaddstr(xf_win, 6, 5, "Est transfer time:");
  38.     mvwaddstr(xf_win, 7, 11, "Block count:");
  39.     mvwaddstr(xf_win, 8, 6, "Percent complete:");
  40.     mvwaddstr(xf_win, 9, 5, "Bytes transferred:");
  41.     mvwaddstr(xf_win, 10, 5, "Errors this block:");
  42.     mvwaddstr(xf_win, 11, 5, "Total error count:");
  43.     mvwaddstr(xf_win, 12, 10, "Last message: NONE");
  44.     box(xf_win, VERT, HORZ);
  45.  
  46.     if (up)
  47.         mvwattrstr(xf_win, 0, 17, A_BOLD, " Uploading ");
  48.     else
  49.         mvwattrstr(xf_win, 0, 16, A_BOLD, " Downloading ");
  50.  
  51.     mvwaddstr(xf_win, 14, 11, " Press <ESC> to abort ");
  52.     wrefresh(xf_win);
  53.                     /* fix up the terminal mode */
  54.     input_off();
  55.     xmodem_mode(fd);
  56.  
  57.     /*
  58.      * Is your terminal slower than the xfer baud rate?  For example:
  59.      * I'm at home with my PC and 1200 baud modem; I call my system
  60.      * at work so I can use their 2400 baud modems to call some other
  61.      * system.  In this case, I don't wanna spend too much time updating
  62.      * my screen at 1200 baud, when I'm transferring the file at 2400 baud.
  63.      */
  64.     fast = 0;
  65.  
  66.     if (my_speed() >= dir->baud[dir->d_cur])
  67.         fast++;
  68.  
  69.     if (up)
  70.         ack_error = send_xmodem(xf_win, list, type, fast);
  71.     else
  72.         ack_error = rcv_xmodem(xf_win, list, type, fast);
  73.  
  74.     tty_noblock(0, FALSE);
  75.                     /* prompt for a key on errors */
  76.     if (ack_error) {
  77.         beep();
  78.         clear_line(xf_win, 13, 9, TRUE);
  79.         wattrstr(xf_win, A_BOLD, "Press any key to continue");
  80.         wrefresh(xf_win);
  81.         wgetch(xf_win);
  82.     }
  83.     werase(xf_win);
  84.     wrefresh(xf_win);
  85.     delwin(xf_win);
  86.                     /* undo what xmodem_mode() did */
  87.     line_set();
  88.     return;
  89. }
  90.